''' Mission 10 - Reaction Time ''' from codex import * import random import time def wait_button(): display.print("Press Button A") while True: if buttons.was_pressed(BTN_A): break # MAIN PROGRAM while True: wait_button() pixels.set([BLACK, BLACK, BLACK, BLACK]) display.clear() display.print(3, scale=6) time.sleep(1) display.print(2, scale=6) time.sleep(1) display.print(1, scale=6) time.sleep(1) display.clear() delay = random.randrange(1000, 5000) delay_time = delay / 1000 time.sleep(delay_time) buttons.was_pressed(BTN_A) #resets early press pixels.set([GREEN, GREEN, GREEN, GREEN]) start_time = time.ticks_ms() wait_button() end_time = time.ticks_ms() elapsed = time.ticks_diff(end_time, start_time) display.print("Reaction Time") display.print(elapsed) display.print("milliseconds") time.sleep(3)